$(document).ready(function(){
	carousel();
	backtop();
	jkcommon.init();
	$('body').scrollspy({ target: '#scrollexample' });
	$('[data-spy="scroll"]').each(function () {
    var $spy = $(this).scrollspy('refresh')
});
$('#scrollexample').on('activate.bs.scrollspy', function () {
   
});
     var $notes=$('<ol id="notes"></ol>').insertBefore('#footer');
     $('span.footnote').each(function(index){
     	$(this).before(['<a href="#footnote-',index+1,'"id="content-',index+1,
     	'"class="content">','<sup>',index+1,'</sup></a>'].join('')).appendTo($notes)
     	.append(['&nbsp;(<a href="#content-',index+1,'" class="linkcontent">content</a>)'].join(''))
     	.wrap('<li id="footnote-'+(index+1)+'" class="noteli"></li>');
     });
});
var jkcommon ={
    init:function(){
        this.lessImgShow();
    },
    stopEventBubble:function(event){
      var e= event;
        if(e){
            e.stopPropagation();
        }
    },
    lessImgShow:function(){
        $('.thumbnail').bind("mouseover",function(e){
            var _pop = $(this).find('.img-pop');
            $(this).css({border:"2px solid #1abc9c",height:"220px"});
            TweenMax.to(_pop,0.5,{top:160,ease:Bounce.easeOut});
            jkcommon.stopEventBubble(e);
        });

        $(document).bind("mouseover",function(){
            $('.thumbnail').css({border:"2px solid #eaeaea",height:"220px"});
            var _pop = $(this).find(".img-pop");
            TweenMax.to(_pop,0.5,{top:220,ease:Linear.easeNone});
        })

    }

}
var carousel=function carouseltrans () {
	 $('#carousel-example-generic').on('slide.bs.carousel',function(){
	 });
}
//回到顶端js
var backtop=function gotop(){
	var $gotop=$('#backtop');
	var timer=null;
	var pagelookheight=document.documentElement.clientHeight;
	window.onscroll=function(){
		var backtop=document.body.scrollTop;
		if (backtop>=pagelookheight) {
			$gotop.style.display="block";
		}else{
			$gotop.style.display="none";
		}
	}
	$gotop.on('click',function(){
//		alert("hello");
		timer=setInterval(function(){
			var backtop=document.body.scrollTop;
			var speed=backtop/5;
		    document.body.scrollTop-=backtop-speed;
		    if (backtop==0) {
		    	clearInterval(timer);
		    }
		},30)
	});
}
